@extends('Home.User.Common.layout')
@section('title')
    兼职渠道_渠道管理
@endsection
@section('content')
    <!--  content  -->
    <main class="common_content">
        <div class="container">
            <div class="ct_main">
                @include('Home.User.Channel.Common.channel_menu')
                <ul class="nav-items1 nav-items2 w999" id="tab-content2">
                    <!--所有兼职渠道-->
                    <li class="basic-sets active">
                        <form class="selector-head">
                            <h2 class="lt">所有兼职渠道</h2>
                            <div class="rt">
                                <a href="javascript:;" class="add-new-btn add-client" onclick="open_button('{{route('add_part')}}','新增兼职渠道')" title="新增兼职渠道"><i class="icon icon-xinzen"></i></a>
                                <a href="javascript:location.replace(location.href);" class="refresh-btn" title="刷新"><i class="icon icon-shuaxin"></i></a>
                            </div>
                        </form>
                        <div class="layui-form basic-sets-ul">
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th class="c-day" style="width: 100px;">创建时间</th>
                                    <th class="c-name" style="width: 114px;">猎头公司名称</th>
                                    <th class="c-contact">联系人/电话</th>
                                    <th class="c-comm" style="width: 104px;">签约情况</th>
                                    <th class="c-corp">合作详情</th>
                                    <th class="c-count">账户/密码</th>
                                    <th class="c-devp">归属于</th>
                                    <th class="c-tac">跟进操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                    @foreach($list as $k => $v)
                                        <tr>
                                            <td data-label="创建时间" title="{{$v->created_at}}">{{$v->created_at}}</td>
                                            <td data-label="客户名称" title="{{$v->chinese_name}}">{{$v->chinese_name}}</td>
                                            <td data-label="联系人/电话" title="{{$v->contacts.'/'.$v->country_code.' '.$v->phone}}">{{$v->contacts.'/'.$v->country_code.' '.$v->phone}}</td>
                                            <td data-label="沟通情况" title="{{$v->one_schedule?$v->one_schedule->result:$v->situation}}">{{$v->one_schedule?$v->one_schedule->result:$v->situation}}</td>
                                            <td data-label="合作详情" title="{{$v->one_schedule?$v->one_schedule->details:''}}">{{$v->one_schedule?$v->one_schedule->details:''}}</td>
                                            <td data-label="账户/密码" title="登录账户：{{$v->create_user?$v->create_user->username:$v->create_username}}，登录密码：{{$v->create_user_password}}">登录账户：{{$v->create_user?$v->create_user->username:$v->create_username}}，登录密码：{{$v->create_user_password}}</td>
                                            <td data-label="归属于" title="{{$v->assign_user?$v->assign_user->username:''}}">{{$v->assign_user?$v->assign_user->username:''}}</td>
                                            <td data-label="跟进操作">
                                                <a href="javascript:;" class="edit-btn edit-client" onclick="open_button('{{route('edit_part',$v->id)}}','查看/编辑兼职渠道')" title="查看/编辑兼职渠道"><i class="layui-icon">&#xe642;</i></a>
                                                <a href="javascript:;" class="edit-btn add-schedule" onclick="open_button('{{route('add_part_schedule',$v->id)}}','查看/添加跟进记录')" title="查看/添加跟进记录"><i class="layui-icon">&#xe63c;</i></a>
                                                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$v->uid)
                                                    <a href="javascript:;" class="edit-btn add-schedule" onclick="del('{{route('del_part',$v->id)}}')" title="删除"><i class="layui-icon">&#xe640;</i></a>
                                                @endif
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>

                            <!-- 分页 s -->
                            @if($num>1)
                                <div class="news-pager">
                                    <ul class="pagination" id="page">
                                    </ul>
                                    <div class="pageJump">
                                        <span>跳转到</span>
                                        <input type="text"/>
                                        <span>页</span>
                                        <button type="button" class="button">确定</button>
                                    </div>
                                </div>
                        @endif
                        <!-- 分页 e -->
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </main>
@endsection
@section('footer')
    <script>
        function del(url) {
            layer.confirm("你确定要删除吗？此操作不能撤销！", {icon: 3, title:'提示'},
                function(index){//确定回调
                    $.ajax({
                        type: 'get',
                        url: url,
                        dataType: 'json',
                        success: function(data){
                            if(data.code){
                                window.location.reload();
                                layer.close(index);
                            }else{
                                layer.msg(data.msg,{icon: 5,time:1000});
                            }
                        },
                        error:function() {
                            layer.msg('服务器错误!',{icon: 5,time:1000});
                        }
                    });
                },function (index) {//取消回调
                    layer.close(index);
                }
            );
        }

        /***  分页 JS  ***/
        Page({
            num: '{{$num}}',		//页码数
            startnum: '{{$page}}',				//指定页码
            elem:$('#page'),		//指定的元素
            callback:function(n){	//回调函数
                window.location.href = '{{route('part_list')}}?page='+n;
            }
        });
    </script>
@endsection